package com.velocity.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;


/**
 * 读取代码生成相关配置
 *
 * @author ast
 */
@Component
@PropertySource(value = {"classpath:generator.yml"})
@ConfigurationProperties(prefix = "gen")
@Data
public class GenConfig {
    /**
     * 作者
     */
    public static String author;

    /**
     * 生成包路径
     */
    public static String packagename;

    /**
     * 自动去除表前缀，默认是false
     */
    public static boolean autoRemovePre;

    /**
     * 表前缀(类名不会包含表前缀)
     */
    public static String tablePrefix;

    /**
     * vm文件默认
     */
    public static Boolean defaultVal;

    /**
     * vm文件默认路径
     */
    public static String modulePath;

    public static String getAuthor() {
        return author;
    }

    @Value("${author}")
    public void setAuthor(String author) {
        GenConfig.author = author;
    }

    public static String getPackagename() {
        return packagename;
    }

    @Value("${packageName}")
    public void setPackageName(String packageName) {
        GenConfig.packagename = packageName;
    }

    public static boolean getAutoRemovePre() {
        return autoRemovePre;
    }
    @Value("${autoRemovePre}")
    public void setAutoRemovePre(boolean autoRemovePre) {
        GenConfig.autoRemovePre = autoRemovePre;
    }

    public static String getTablePrefix() {
        return tablePrefix;
    }

    public void setTablePrefix(String tablePrefix) {
        GenConfig.tablePrefix = tablePrefix;
    }

    public static Boolean getDefaultVal() {
        return defaultVal;
    }
    @Value("${defaultVal}")
    public void setDefaultVal(Boolean defaultVal) {
        GenConfig.defaultVal = defaultVal;
    }

    public static String getModulePath() {
        return modulePath;
    }
    @Value("${modulePath}")
    public  void setModulePath(String modulePath) {
        GenConfig.modulePath = modulePath;
    }

}
